package com.example.huiyun

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.activity.ComponentActivity
import androidx.activity.enableEdgeToEdge
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.huiyun.adapter.ImageAdapter


class MainActivity : ComponentActivity() {
    private var adapter: ImageAdapter? = null
    private var recyclerView: RecyclerView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(com.example.huiyun.R.layout.activity_layout_main)
        intiView();
    }

    private fun intiView() {


        /**
         * 横向滑动,只需要自定义界面样式即可
         */
        recyclerView = findViewById<View>(com.example.huiyun.R.id.recyclerView) as RecyclerView?
        recyclerView?.setLayoutManager(
            LinearLayoutManager(
                this,
                LinearLayoutManager.HORIZONTAL,
                false
            )
        ) // 3列网格布局


        val imageUrls = arrayListOf("R", "r2", "Rer3", "Rnumber4", "R", "r2", "Rer3", "Rnumber4")
        adapter = ImageAdapter(this, imageUrls);
        recyclerView?.adapter = adapter

        findViewById<ImageView>(R.id.img_home)?.setOnClickListener(View.OnClickListener {

            this.finish()
        })
    }
}
